package net.acoder.util;

public class ArrayUtil {
    public final static String toString(short[] array) {
        if (array == null) {
            return Constants.NULL_STRING;
        }
        if (array.length == 0) {
            return Constants.EMPTY_ARRAY;
        }
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        buf.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            buf.append(", ");
            buf.append(array[i]);
        }
        buf.append(']');
        return buf.toString();
    }

    public final static String toString(byte[] array) {
        if (array == null) {
            return Constants.NULL_STRING;
        }
        if (array.length == 0) {
            return Constants.EMPTY_ARRAY;
        }
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        buf.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            buf.append(", ");
            buf.append(array[i]);
        }
        buf.append(']');
        return buf.toString();
    }

    public final static String toString(int[] array) {
        if (array == null) {
            return Constants.NULL_STRING;
        }
        if (array.length == 0) {
            return Constants.EMPTY_ARRAY;
        }
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        buf.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            buf.append(", ");
            buf.append(array[i]);
        }
        buf.append(']');
        return buf.toString();
    }

    public final static String toString(long[] array) {
        if (array == null) {
            return Constants.NULL_STRING;
        }
        if (array.length == 0) {
            return Constants.EMPTY_ARRAY;
        }
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        buf.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            buf.append(", ");
            buf.append(array[i]);
        }
        buf.append(']');
        return buf.toString();
    }

    public final static String toString(char[] array) {
        if (array == null) {
            return Constants.NULL_STRING;
        }
        if (array.length == 0) {
            return Constants.EMPTY_ARRAY;
        }
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        buf.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            buf.append(", ");
            buf.append(array[i]);
        }
        buf.append(']');
        return buf.toString();
    }

    public final static String toString(boolean[] array) {
        if (array == null) {
            return Constants.NULL_STRING;
        }
        if (array.length == 0) {
            return Constants.EMPTY_ARRAY;
        }
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        buf.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            buf.append(", ");
            buf.append(array[i]);
        }
        buf.append(']');
        return buf.toString();
    }

    public final static String toString(float[] array) {
        if (array == null) {
            return Constants.NULL_STRING;
        }
        if (array.length == 0) {
            return Constants.EMPTY_ARRAY;
        }
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        buf.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            buf.append(", ");
            buf.append(array[i]);
        }
        buf.append(']');
        return buf.toString();
    }

    public final static String toString(double[] array) {
        if (array == null) {
            return Constants.NULL_STRING;
        }
        if (array.length == 0) {
            return Constants.EMPTY_ARRAY;
        }
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        buf.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            buf.append(", ");
            buf.append(array[i]);
        }
        buf.append(']');
        return buf.toString();
    }

    public final static String toString(Object[] array) {
        if (array == null) {
            return Constants.NULL_STRING;
        }
        if (array.length == 0) {
            return Constants.EMPTY_ARRAY;
        }
        StringBuffer buf = new StringBuffer();
        buf.append('[');
        buf.append(array[0]);
        for (int i = 1; i < array.length; i++) {
            buf.append(", ");
            buf.append(String.valueOf(array[i]));
        }
        buf.append(']');
        return buf.toString();
    }

    public final static boolean equals(boolean[] a1, boolean[] a2) {
        if (a1 == a2) {
            return true;
        }
        if (a1 == null || a2 == null) {
            return false;
        }
        int len = a1.length;
        if (len != a2.length) {
            return false;
        }
        for (int i = 0; i < len; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }

    public final static boolean equals(byte[] a1, byte[] a2) {
        if (a1 == a2) {
            return true;
        }
        if (a1 == null || a2 == null) {
            return false;
        }
        int len = a1.length;
        if (len != a2.length) {
            return false;
        }
        for (int i = 0; i < len; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }

    public final static boolean equals(char[] a1, char[] a2) {
        if (a1 == a2) {
            return true;
        }
        if (a1 == null || a2 == null) {
            return false;
        }
        int len = a1.length;
        if (len != a2.length) {
            return false;
        }
        for (int i = 0; i < len; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }

    public final static boolean equals(double[] a1, double[] a2) {
        if (a1 == a2) {
            return true;
        }
        if (a1 == null || a2 == null) {
            return false;
        }
        int len = a1.length;
        if (len != a2.length) {
            return false;
        }
        for (int i = 0; i < len; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }

    public final static boolean equals(float[] a1, float[] a2) {
        if (a1 == a2) {
            return true;
        }
        if (a1 == null || a2 == null) {
            return false;
        }
        int len = a1.length;
        if (len != a2.length) {
            return false;
        }
        for (int i = 0; i < len; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }

    public final static boolean equals(int[] a1, int[] a2) {
        if (a1 == a2) {
            return true;
        }
        if (a1 == null || a2 == null) {
            return false;
        }
        int len = a1.length;
        if (len != a2.length) {
            return false;
        }
        for (int i = 0; i < len; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }

    public final static boolean equals(long[] a1, long[] a2) {
        if (a1 == a2) {
            return true;
        }
        if (a1 == null || a2 == null) {
            return false;
        }
        int len = a1.length;
        if (len != a2.length) {
            return false;
        }
        for (int i = 0; i < len; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }

    public final static boolean equals(short[] a1, short[] a2) {
        if (a1 == a2) {
            return true;
        }
        if (a1 == null || a2 == null) {
            return false;
        }
        int len = a1.length;
        if (len != a2.length) {
            return false;
        }
        for (int i = 0; i < len; i++) {
            if (a1[i] != a2[i]) {
                return false;
            }
        }
        return true;
    }

    public final static boolean equals(Object[] a1, Object[] a2) {
        if (a1 == a2) {
            return true;
        }
        if (a1 == null || a2 == null) {
            return false;
        }
        int len = a1.length;
        if (len != a2.length) {
            return false;
        }
        for (int i = 0; i < len; i++) {
            Object o1 = a1[i];
            Object o2 = a2[i];
            if (!(o1 == null ? o2 == null : o1.equals(o2))) {
                return false;
            }
        }
        return true;
    }
}
